package com.cskaoyan.market.service;

import com.cskaoyan.market.db.domain.MarketComment;
import com.cskaoyan.market.db.domain.MarketCommentExample;
import com.cskaoyan.market.db.mapper.MarketCommentMapper;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: MYM
 * @Date: 2024/05/19/22:12
 * @Description:
 */
@Service
public class MarketAdminCommentServiceImpl implements MarketAdminCommentService{
    @Autowired
    private MarketCommentMapper marketCommentMapper;
    @Override
    public List<MarketComment> list(Integer page, Integer limit, Integer userId, Integer valueId, String sort, String order) {
        MarketCommentExample example = new MarketCommentExample();
        example.setOrderByClause(sort + " " + order);
        if (userId!= null) {
            example.createCriteria().andUserIdEqualTo(userId);
        }
        System.out.println(userId);
        if (valueId!= null) {
            example.createCriteria().andValueIdEqualTo(valueId);
        }
        System.out.println(valueId);
        PageHelper.startPage(page, limit);
        return marketCommentMapper.selectByExample(example);
    }

    @Override
    public void delete(Integer id) {
        MarketCommentExample example = new MarketCommentExample();
        example.createCriteria().andIdEqualTo(id);
        marketCommentMapper.deleteByExample(example);
    }
}
